package oop.inherit.autoCar;

//轮胎个数，汽车颜色，车身重量、速度等成员变量
//并通过不同的构造方法创建实例
//至少要求 汽车能够加速，减速，停车
public class Auto {

    int tyreCount;
    String color;
    double weight;
    public int speed;

    public Auto(int tyreCount, String color, double weight, int speed) {
        this.tyreCount = tyreCount;
        this.color = color;
        this.weight = weight;
        this.speed = speed;
    }

    public void addSpeed(int speed){
        this.speed += speed;
    }

    public void subSpeed(int speed){
        this.speed -= speed;
        if(this.speed<0){
            this.speed = 0;
        }
    }

    public void stop(){
        this.speed = 0;
        System.out.println("停车了");
    }
}
